package com.lz.ht.service.serviceImpl;

import com.lz.ht.dao.RoomDao;
import com.lz.ht.dao.RoomlogDao;
import com.lz.ht.model.Room;
import com.lz.ht.model.Roomlog;
import com.lz.ht.page.PageModel;
import com.lz.ht.service.RoomLogService;
import com.lz.ht.util.ToolKit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * @ClassName: RoomLogServiceImpl
 * @Description:
 * @Author: CHonghao
 * @Date: 2021/7/9 16:28
 * @Version: V1.0
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class RoomLogServiceImpl implements RoomLogService {
    @Autowired
    private RoomlogDao roomlogDao;

    @Override
    public List<Roomlog> findPageList(PageModel<Roomlog> page, Roomlog roomlog) throws Exception {
        HashMap<String, Object> hashMap = ToolKit.javaBeanToMap(roomlog);
        hashMap.put("msFirst", page.getMsFirst());
        hashMap.put("msLast", page.getMsLast());
        List<Roomlog> pageList = roomlogDao.findListByMapLimit(hashMap);
        return pageList;
    }

    @Override
    public long findCount(Roomlog roomlog) throws Exception {
        HashMap<String, Object> hashMap = ToolKit.javaBeanToMap(roomlog);
        return roomlogDao.findCountByMap(hashMap);
    }
}
